Figured out problem with loading Progressive JPEG's progressively (say
authorMichael Fulbright <drmike@redhat.com>
Tue, 9 Nov 1999 17:24:15 +0000 (17:24 +0000)
committerMichael Fulbright <drmike@src.gnome.org>
Tue, 9 Nov 1999 17:24:15 +0000 (17:24 +0000)
1999-11-09  Michael Fulbright  <drmike@redhat.com>

* src/io-jpeg.c (image_load_increment): Figured out problem with
loading Progressive JPEG's progressively (say that 10 times fast).
Currently for Progressive JPEG's the entire image is loaded before
it is displayed. libjpeg supports a fancier mechanism which I may
implement later.

With these changes all JPEG formats appear to load properly for me.

gdk-pixbuf/ChangeLog
gdk-pixbuf/io-jpeg.c

index da24c73ba0d7e462fd5807a068bb1a03217fdeb1..992178ea945e7928fc10a0f524493c656b3f4f03 100644 (file)
@@ -2,6 +2,14 @@
 
        * src/io-pnm.c : Finished progressive PNM loading code. Should handle
        all types of PNM files now.
+
+       * src/io-jpeg.c (image_load_increment): Figured out problem with
+       loading Progressive JPEG's progressively (say that 10 times fast).
+       Currently for Progressive JPEG's the entire image is loaded before
+       it is displayed. libjpeg supports a fancier mechanism which I may
+       implement later.
+
+       With these changes all JPEG formats appear to load properly for me.
        
 1999-11-08  Jonathan Blandford  <jrb@redhat.com>
 
index 119e9e51739ecee40b4d260c5246588f6f8b3992..208ec01923ce8e03646b65c69d92cb3425ab024b 100644 (file)
@@ -354,6 +354,7 @@ image_load_increment (gpointer data, guchar *buf, guint size)
        guint       num_left, num_copy;
        guint       last_bytes_left;
        guint       spinguard;
+       gboolean    first;
        guchar *bufhd;
 
        g_return_val_if_fail (context != NULL, FALSE);
@@ -384,10 +385,13 @@ image_load_increment (gpointer data, guchar *buf, guint size)
                bufhd = buf;
        }
 
+       if (num_left == 0)
+               return TRUE;
 
        last_bytes_left = 0;
        spinguard = 0;
-       while (src->pub.bytes_in_buffer != 0 || num_left != 0) {
+       first = TRUE;
+       while (TRUE) {
 
                /* handle any data from caller we haven't processed yet */
                if (num_left > 0) {
@@ -410,9 +414,10 @@ image_load_increment (gpointer data, guchar *buf, guint size)
                        num_left -= num_copy;
                } else {
                /* did anything change from last pass, if not return */
-                       if (last_bytes_left == 0)
+                       if (first) {
                                last_bytes_left = src->pub.bytes_in_buffer;
-                       else if (src->pub.bytes_in_buffer == last_bytes_left)
+                               first = FALSE;
+                       } else if (src->pub.bytes_in_buffer == last_bytes_left)
                                spinguard++;
                        else
                                last_bytes_left = src->pub.bytes_in_buffer;
@@ -434,12 +439,13 @@ image_load_increment (gpointer data, guchar *buf, guint size)
 
                        context->got_header = TRUE;
 
+#if 0
                        if (jpeg_has_multiple_scans (cinfo)) {
                                g_print ("io-jpeg.c: Does not currently "
                                         "support progressive jpeg files.\n");
                                return FALSE;
                        }
-
+#endif
                        context->pixbuf = gdk_pixbuf_new(ART_PIX_RGB, 
                                                         /*have_alpha*/ FALSE,
                                                         8, 
@@ -471,6 +477,7 @@ image_load_increment (gpointer data, guchar *buf, guint size)
 
                        context->did_prescan = TRUE;
                } else {
+
                        /* we're decompressing so feed jpeg lib scanlines */
                        guchar *lines[4];
                        guchar **lptr;
@@ -488,11 +495,6 @@ image_load_increment (gpointer data, guchar *buf, guint size)
                                        rowptr += context->pixbuf->art_pixbuf->rowstride;;
                                }
 
-#ifdef IO_JPEG_DEBUG_GREY
-                               for (p=lines[0],i=0; i< context->pixbuf->art_pixbuf->rowstride;i++, p++)
-                                       *p = 0;
-                               
-#endif
                                nlines = jpeg_read_scanlines (cinfo, lines,
                                                              cinfo->rec_outbuf_height);
                                if (nlines == 0)